package com.ruoyi.syf.controller;

import java.util.List;

import com.ruoyi.syf.domain.vo.RiskCheckVo;
import com.ruoyi.syf.service.IRiskCheckRecordService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 排查记录
 *
 * @author yr
 * @date 2024-07-31
 */
@RestController
@RequestMapping("/syf/record")
public class RiskCheckRecordController extends BaseController {
    @Autowired
    private IRiskCheckRecordService riskCheckRecordService;

    /**
     * 查询排查记录列表
     */
    @GetMapping("/list")
    public TableDataInfo list(RiskCheckVo vo) {
        startPage();
        List<RiskCheckVo> list = riskCheckRecordService.list(vo);
        return getDataTable(list);
    }

    /**
     * 获取排查记录详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(riskCheckRecordService.getInfo(id));
    }

    /**
     * 新增排查记录
     */
    @PreAuthorize("@ss.hasPermi('syf:record:add')")
    @Log(title = "排查记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RiskCheckVo vo) {
        return toAjax(riskCheckRecordService.mySave(vo));
    }

    /**
     * 修改
     */
    @Log(title = "排查记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult update(@RequestBody RiskCheckVo vo) throws IllegalAccessException {
        return toAjax(riskCheckRecordService.myUpdate(vo));
    }

    /**
     * 排查
     */
    @Log(title = "排查记录", businessType = BusinessType.UPDATE)
    @PutMapping("/check")
    public AjaxResult check(@RequestBody RiskCheckVo vo) throws IllegalAccessException {
        return toAjax(riskCheckRecordService.check(vo));
    }

    /**
     * 无隐患
     */
    @Log(title = "排查记录", businessType = BusinessType.UPDATE)
    @PutMapping("/normal")
    public AjaxResult normalById(@RequestBody RiskCheckVo vo) throws IllegalAccessException {
        return toAjax(riskCheckRecordService.normal(vo));
    }

    /**
     * 回退
     */
    @Log(title = "排查记录", businessType = BusinessType.UPDATE)
    @PutMapping("/back/{id}")
    public AjaxResult backById(@PathVariable("id") Long id) throws IllegalAccessException {
        return toAjax(riskCheckRecordService.backById(id));
    }

    /**
     * 隐患确认
     */
    @Log(title = "排查记录", businessType = BusinessType.UPDATE)
    @PutMapping("/confirm/{id}")
    public AjaxResult confirmById(@PathVariable("id") Long id) throws IllegalAccessException {
        return toAjax(riskCheckRecordService.confirmById(id));
    }

    /**
     * 不采纳
     */
    @Log(title = "排查记录", businessType = BusinessType.UPDATE)
    @PutMapping("/noAdoption/{id}")
    public AjaxResult noAdoptionById(@PathVariable("id") Long id) throws IllegalAccessException {
        return toAjax(riskCheckRecordService.noAdoptionById(id));
    }

    /**
     * 转派
     */
    @Log(title = "排查记录", businessType = BusinessType.UPDATE)
    @PutMapping("/forward")
    public AjaxResult forwardById(@RequestBody RiskCheckVo vo) throws IllegalAccessException {
        return toAjax(riskCheckRecordService.forwardById(vo));
    }

    /**
     * 删除排查记录
     */
    @PreAuthorize("@ss.hasPermi('syf:record:remove')")
    @Log(title = "排查记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(riskCheckRecordService.deleteByIds(ids));
    }
}
